<?PHP
	require 'includes/master.inc.php';
	$auth->admin();

	if(isset($_GET['reset']) && $_GET['reset'] == 'paypal_url')
	{
		set_option('paypal_url', DEFAULT_PAYPAL_URL);
		redirect('options.php');
	}

	if(isset($_POST['btnsubmit']))
	{
		if($Error->ok())
		{
			set_option('paypal_url', $_POST['paypal_url']);
			redirect('options.php?saved=1');
		}
	}

	$paypal_url = get_option('paypal_url', DEFAULT_PAYPAL_URL);
	
	if(isset($_GET['saved']) && $_GET['saved'] == '1')
		$msg = '<p class="alert">Your changes have been saved.</p>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>Options | Appcaster</title>
	<?PHP include 'inc/meta.inc.php'; ?>
	<script type="text/javascript" charset="utf-8">
		$(function() {
			$('a.default').click(function() {
				return confirm("Are you sure you want to reset this option?");
			});
		});
	</script>
</head>

<body id="home">
	<?PHP include 'inc/head.inc.php'; ?>
	<div id="nav">
		<ul>
			<li><a href='<?PHP WEBROOT();?>index.php'>Applications</a></li>
			<li><a href='<?PHP WEBROOT();?>orders.php'>Orders</a></li>
			<li><a href='<?PHP WEBROOT();?>feedback.php'>Feedback (<?PHP echo Feedback::newCountTotal();?>)</a></li>
			<li><a href='<?PHP WEBROOT();?>stats.php'>Stats</a></li>
			<li class="selected"><a href='<?PHP WEBROOT();?>options.php'>Options</a></li>
		</ul>
	</div>

	<div id="menutabs">
		<ul id="tabnav">
			<li class="selected"><a href='<?PHP WEBROOT();?>options.php'>Options</a></li>
		</ul>
	</div>

	<div id="contain">
		<?PHP if(isset($msg)) echo $msg; ?>
		<form action="" method="post">
			<fieldset>
				<legend>PayPal Info</legend>
				<p><label for="paypal_url">PayPal URL:</label> <input type="text" name="paypal_url" value="<?PHP echo $paypal_url;?>" id="paypal_url" class="text" /> (<a href="options.php?reset=paypal_url" class="default">Reset to Default</a>)</p>
				<p><input type="submit" name="btnsubmit" value="Save Options" id="btnsubmit"/></p>
			</fieldset>
		</form>
	</div>
</body>
</html>